﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XF.FM.Core.Table
{
    public class PageRequest
    {
        /// <summary>
        /// 页码,默认0
        /// </summary>
        public int Start { get; set; }
        /// <summary>
        /// 每页多少条数据
        /// </summary>
        public int Length { get; set; } = 10;

        public PageData<T> GetData<T>(IQueryable<T> source)
        {
            PageData<T> page = new PageData<T>();
            page.Length = Length;
            page.Index = Start;
            page.Total = source.Count();
            page.Data = source.Skip(Start * Length).Take(Length);
            return page;
        }
    }
}
